﻿

var $core = new function () {


    this.dateRange = function (from, to, noOfMonths) {

        var fromId = this.getId(from);
        var toId = this.getId(to);
        var datepickerRangeControls = fromId + ', ' + toId ;

        var dates = $(datepickerRangeControls).datepicker({
            defaultDate: "+1w",
            changeMonth: true,
            numberOfMonths: noOfMonths,
            onSelect: function (selectedDate) {
                var option = this.id == from ? "minDate" : "maxDate",
					instance = $(this).data("datepicker"),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings);
                dates.not(this).datepicker("option", option, date);
            }
        });
    }


    this.button = function (id) {
        $(this.getId(id)).button();
    }

    this.getId = function (id) {
        return '#' + id;
    }

    this.test = function () {
        alert('Test ...');
    }
}